package com.wrial.simple;
/*
 * @Author  Wrial
 * @Date Created in 22:39 2020/3/23
 * @Description  155
 */

import java.util.Stack;

public class LeetCode_155 {


    Stack<Node> stack;


    /**
     * initialize your data structure here.
     */
    public LeetCode_155() {
        stack = new Stack<>();
    }

    public void push(int x) {
       if (stack.empty()){
           stack.push(new Node(x, x));
       }else {
           stack.push(new Node(Integer.min(stack.peek().min, x), x));
       }
    }

    public void pop() {
        stack.pop();
    }

    public int top() {
      return   stack.peek().num;
    }

    public int getMin() {

        return stack.peek().min;
    }

    class Node{
        int min;
        int num;
        Node(int min,int num){
            this.min = min;
            this.num = num;
        }

    }

}
